const mongoose = require('mongoose')
const Message = require('../../model/message')
const pagination = require('mongoose-sex-page');

module.exports = async (req, res) => {
    const page = req.params.page
    try {
        var data = await pagination(Message).find({status:true}).page(page).populate('author').size(7).exec()
    } catch (error) {
        return res.send({
            data: null,
            meta: {
                status: 400,
                msg: '请求失败'
            }
        })
    }
    res.send({
        data,
        meta: {
            status: 200,
            msg: '请求成功'
        }
    })
}